<template>
	<view>
		<view style="padding-bottom: 200rpx;">
			<view class="leaveNav">
				<view @click="attendanceTtileFun()" style="margin-left:-80rpx;font-weight: 800;">考勤状况
					<view class="leaveLine" v-show="isShowTitle"></view>
				</view>
				<view @click="attendanceTtileFun()"  style="margin-left:100rpx;font-weight: 800;" >违纪状况
					<view class="leaveLine" v-show="!isShowTitle"></view>
				</view>
			</view>
			<view class="leaveMgm"  v-for="(item,index) in attArr" :key="item.id">
				<view v-show="isShowTitle" >

						<view style="display: flex;flex-direction: row;">
							<view class="leaveCheck" value="yes" @click="checkFun(item)"></view>
							<view style="width:40%;font-size: 38rpx;">{{item.studentName}}</view>
							<view class="attBtn" v-for="(i,index) in item.typeList"  @click="attBtnSkip(i,item.typeList)">
								<button  :class="[{'attBtnFontSlec':i.isShow},'attBtnFont']">{{i.type}}</button>
							</view>
						</view>

					<view v-if="attArr.length>index+1" class="attLine"></view>
				</view>
			</view>
			<view class="leaveMgm1"  v-for="(item,num) in attArr1" :key="num">
				<view v-show="!isShowTitle">

						<view style="display: flex;flex-direction: row;">
							<view class="leaveCheck1" value="yes"></view>
							<view style="width:20%;font-size: 38rpx;">{{item.studentName}}</view>
							<view class="attBtn1" v-for="(i,num) in item.disArr" :key="num" @click="attBtnSkip(i,item.disArr)">
								<button  :class="[{'attBtnFontSlec':i.isShow},'attBtnFont1']">{{i.type}}</button>
							</view>
						</view>

					<view v-if="attArr.length>num+1" class="attLine1"></view>
				</view>
			</view>
		</view>


		<view class="bottomContent">
			<view class="bottom_nav_wrap" >

			        <view  v-for="(item,index) in attendanceArr" :key="index" >
			            <view @click="changeTime(item)">
			                <view class="bottom_nav_content"  >

			                    <view class="bottom-nav-text " :class="item.icon" :style="{color: item.timeSlot==timeSlot ?'#2934D1':''}"></view>
			                    <text class="bottom_nav_font_cancel blue" :style="{color: item.timeSlot==timeSlot ?'#2934D1':''}">{{item.text}}</text>
			                </view>
			            </view>
			        </view>
			</view>
		</view>


	</view>
</template>

<script>
	import topCom from '../component/topCom.vue'
	import bottomCom from '../component/bottom.vue'
	import headTitle from '../component/btnHeadeCom.vue'
	export default {
		name:'leveRegistration',
		data(){
			return{
				isShowTitle:true,
				userInfo:'',
				isShowList:false,
				userName:'',
				topName:'',
				titleHead:'考勤状况',
				bottomName:'moring',
				attArr:[
					{	id:202,
						student:'欧阳修',
						dormitoryNum:'202宿舍',
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						isShow:false,
						time:'请假时间',
					},
					{	id:203,
						student:'范增',
						dormitoryNum:'202宿舍',
						isShow:false,
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						time:'请假时间',
					},
					{
						id:204,
						student:'杜甫',
						isShow:false,
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						dormitoryNum:'202宿舍',
						time:'请假时间',
					},
					{
						id:205,
						student:'李白',
						typeList:[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}],
						isShow:false,
						dormitoryNum:'202宿舍',
						time:'请假时间',
					}
				],
				attendanceArr:[{
                    name:'moring',
                    icon:'iconfont icon-yonghutongji',
                    text:"上午",
					timeSlot:1,
                    path: `/pages/classManagement/classManageAttendanceDetail`
                },
				{
				    name:'moon',
				    icon:'iconfont icon-yonghutongji',
				    text:"下午",
					timeSlot:2,
				    path: `/pages/classManagement/classManageAttendanceDetail`
				},
				{
				    name:'night',
					timeSlot:3,
				    icon:'iconfont icon-yonghutongji',
				    text:"晚上",
				    path: `/pages/classManagement/classManageAttendanceDetail`
				},],
				attArr1:[
					{
						student:'欧阳修',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					},
					{
						student:'范增',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					},
					{
						student:'杜甫',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					},
					{
						student:'李白',
						dormitoryNum:'202宿舍',
						time:'请假时间',
						disArr:[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"玩游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}],
					}
				],
				classId:'',
				timeSlot:1,
			}
		},
		components:{
			topCom,
			bottomCom,
			headTitle,
		},
		onShow(){
			alert
			var that = this
			uni.getStorage({
				key:"userInfo",
				success:(res)=>{
					that.userInfo  = res.data
					that.userName = res.data
				}
			})

		},
		onLoad(options) {

			this.topName = options.className
			this.classId = options.classId
			this.timeSlot = options.timeSlot;
		},
		mounted(){
			this.tecClassAttence()
			this.getAppClaStuAttenceListByCId()
		},
		methods:{
			changeTime(item){
				this.timeSlot =item.timeSlot;
				this.tecClassAttence()
				this.getAppClaStuAttenceListByCId()
			},
			bottomSkip(item){
				console.log(item)
			},
			getAppClaStuAttenceListByCId(){
				this.$api.teacher.getAppClaStuAttenceListByCId(this.classId,this.$date,this.timeSlot).then(res=>{
					this.attArr1 = res.data
					console.log(this.attArr1)
					this.attArr1.forEach((item,index)=>{
						item.disArr=[{
							type:"着装",
							isShow:false
						},{
							type:"睡觉",
							isShow:false},{
							type:"游戏",
							isShow:false},{
							type:"外出",
							isShow:false},{
							type:"抽烟",
							isShow:false}]
							// 违纪类型 1:着装 2:睡觉 3:玩游戏 4:外出 5:抽烟
							if(item.dvType==1){
								item.disArr[0].isShow = true
							}else if(item.dvType == 2){
								item.disArr[1].isShow = true
							}else if(item.dvType == 3){
								item.disArr[2].isShow = true
							}else if(item.dvType == 4){
								item.disArr[3].isShow = true
							}else if(item.dvType == 5){
								item.disArr[4].isShow = true
							}
							console.log(item,"disarr")
					})



				}).catch(e=>{

				})
			},
			tecClassAttence(){
				this.$api.teacher.tecClassAttence(this.$date,this.timeSlot,this.classId).then(res=>{
					this.attArr = res.data
					this.attArr.forEach((item,index)=>{
						var typeList =	[{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}]
						item.typeList = [{
							type:"正常",
							isShow:false,
						},{
							type:"迟到",
							isShow:false,
						},{
							type:"请假",
							isShow:false,
						}]
						if(item.attenceStatus ==1){
							item.typeList[0].isShow = true
						}else if(item.attenceStatus ==2){
							item.typeList[1].isShow = true
						}else if(item.attenceStatus == 3){
							item.typeList[2].isShow = true
						}
					})
				}).catch(e=>{

					 })
			},
			leaveIndexSkip(item){
				uni.navigateTo({
					// url: '/pages/leave/leaveManagement',
					// success: res => {},
					// fail: () => {},
					// complete: () => {}
				});
			},
			attBtnSkip(item,arr){
				for (let i in arr) {
					if(item.type!=arr[i].type){
						arr[i].isShow = false
					}
				}
				item.isShow = true
				this.$forceUpdate()
			},
			checkFun(item){

			},
			attendanceTtileFun(){
				this.isShowTitle = !this.isShowTitle
			}
		}
	}
</script>

<style>
	.attBtn1{
		margin-right:4rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top:-20rpx;
	}
	.leaveNav{
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: row;
		font-size: 36upx;
		color:blue;
		width:100%;
		padding:50upx
	}
	.leaveBtn{
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		background-size: 100%;
		width:190upx;
		height:60upx;
		color:white;
		font-size: 26upx;
		font-weight: 0;
	}
	.leaveLine{
		width:200upx;
		height:8upx;
		background:rgba(239, 220, 11, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -10upx;
		left:-30upx;
	}
	.leaveMgm{
		color:#808080;
		font-size: 28upx;
		margin-top:50rpx;
	}
	.leaveMgm1{
		color:#808080;
		font-size: 28upx;
		margin-top:50rpx;
		margin-left:20rpx;
	}
	.leaveCheck{
		margin-left:60upx;
		margin-bottom: 30upx;

	}
	.attBtnFontSlec{
		border:solid #007AFF !important ;border-radius: 15upx;font-size: 30rpx;
		color:white;
		background-color: #007AFF;
	}
	.attBtnFont{
		border:solid #808080 0rpx !important;;font-size: 30rpx;
	}
	.attBtnFont1{
		border:solid #808080 0rpx !important;;font-size: 30rpx;
		padding-left: 18rpx !important;
		padding-right: 18rpx !important;
	}
	.attLine{
		width:720rpx;
		height:3upx;
		background:rgba(239, 237, 236, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -18rpx;
		left:-1px;
	}
	.attLine1{
		width:720rpx;
		height:3upx;
		background:rgba(239, 237, 236, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -18rpx;
		left:-10px;
	}
	.attBtn{
		width:60%;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top:-20upx;

	}
	.leaveBtn{
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		width:190upx;
		height:60upx;
		color:white;
		font-size: 26upx;
		font-weight: 0;
	}
	.leaveLine{
		width:200upx;
		height:8upx;
		background:rgba(239, 220, 11, 1.0);
		opacity:0.78;
		position: relative;
		bottom: -10rpx;
		left:-30upx;
	}

	.leaveCheck1{
		margin-left:28rpx;
		margin-bottom: 30upx;
	}
	.leaveCheck{
		margin-left:50rpx;
		margin-bottom: 30upx;
	}
	.checkout{
		display: flex;
		justify-content: space-around;
		align-content: space-between;
	}
	.leaveTabLine{
		width:3upx;
		height:60upx;
		background:#8F8F94;
		opacity:0.78;
		position: relative;
		top: 0upx;
		left:150upx;
	}
	.indexContent{
		height: unset !important;

	}
	@font-face {
	  font-family: 'iconfont';  /* project id 3303366 */
	  src: url('');
	  src: url('?#iefix') format('embedded-opentype'),
	  url('https://at.alicdn.com/t/font_3303366_3ied7mxip0t.woff2') format('woff2'),
	  url('https://at.alicdn.com/t/font_3303366_3ied7mxip0t.woff') format('woff'),
	  url('https://at.alicdn.com/t/font_3303366_3ied7mxip0t.ttf') format('truetype'),
	  url('#iconfont') format('svg');
	}
	.blue{
		color:#2934D1
	}
	.bottomContent{
		position: fixed;
		bottom: 0rpx;
		left:0rpx;
		box-shadow: 10rpx 0rpx 10rpx 0rpx #8F8F94;
		width:100%;
		height: 0rpx;
		background-color: white;
		z-index:99999
	}
	 .bottom_nav_wrap{
	        width:750rpx;
	        height:80rpx;
	        background:rgba(255,255,255,1);
	        box-shadow:0px -1rpx 10rpx 0rpx rgba(104,57,182,0.2);
	        display: flex;
	        justify-content: space-around;
	        align-content: space-between;
	        position:fixed;
	        bottom:0;
	        left:0;
	        padding-top:18rpx;
	        padding-bottom: 20rpx;
	    }
	    .bottom_nav_content{
	        display: flex;
	        flex-direction: column;
			align-items:center ;

	    }
	    .select-color {
	        color:blue!important;
	    }
	    .bottom-nav-text{
	        font-size: 32rpx;
	        color:rgba(161,161,161,1);
	    }
	    .bottom_nav_font{
	        font-size:32rpx;
	        font-family:Source Han Serif SC;
	        font-weight:bold;
	        color:blue;
	        line-height:24rpx;
	        margin-top:20rpx;
	        /* margin-left:-3rpx; */
	    }
	    .bottom_nav_font_cancel{
	        font-size:32rpx;
	        font-family:Source Han Serif SC;
	        font-weight:bold;
	        color:rgba(161,161,161,1);
	        line-height:24rpx;
	        margin-top:20rpx;
	        /* margin-left:-3rpx; */
	    }
</style>
